Completed
Push — master ( a8c4d7...401d4c )
by Michael
12s queued 10s
created

MenuView.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 1
dl 0
loc 1
c 0
b 0
f 0
cc 1
nop 2
rs 10
1
class MenuView {
2
    /**
3
     * @param {[MenuItem]} items
4
     * @param {EditorView} editorView
5
     *
6
     * @return {void}
7
     */
8
    constructor(items, editorView) {
9
        this.items = items;
10
        this.editorView = editorView;
11
12
        this.dom = document.createElement('div');
13
        this.dom.className = 'menubar';
14
        items.forEach(menuItem => this.dom.appendChild(menuItem.render(editorView)));
15
        this.update(editorView);
16
    }
17
18
    /**
19
     * Called by Prosemirror when the state of the editor changes
20
     *
21
     * @param {EditorView} editorView
22
     *
23
     * @return {void}
24
     */
25
    update(editorView) {
26
        this.items.forEach((item) => {
27
            item.update(editorView);
28
        });
29
    }
30
31
    /**
32
     * Called by Prosemirror when the menu is removed
33
     *
34
     * @return {void}
35
     */
36
    destroy() {
37
        this.dom.remove();
38
    }
39
}
40
41
export default MenuView;
42